package drds.global_transaction.resource_manager;

import drds.global_transaction.api.rpc.rpc_client.resource_manager.ResourceManagerClientMessageListener;
import drds.global_transaction.api.rpc.rpc_client.resource_manager.ResourceManagerRpcClient;

public class ResourceManagerClient
{

	public static void init(String applicationId, String transactionServiceGroup)
	{
		ResourceManagerRpcClient resourceManagerRpcClient = ResourceManagerRpcClient.getInstance(applicationId, transactionServiceGroup);
		AsyncPhase2CommitWorker asyncPhase2CommitWorker = new AsyncPhase2CommitWorker();
		asyncPhase2CommitWorker.init();
		ResourceManager.init(asyncPhase2CommitWorker);
		resourceManagerRpcClient.setResourceManager(ResourceManager.get());
		resourceManagerRpcClient.setResourceManagerClientMessageListener(new ResourceManagerClientMessageListener(new ResourceManagerHandler()));
		resourceManagerRpcClient.init();
	}
}
